package com.lookoutthebush.companyindex.controller;

import com.lookoutthebush.companyindex.domain.UsersDO;
import com.lookoutthebush.companyindex.exception.BizException;
import com.lookoutthebush.companyindex.services.IUsersService;
import com.lookoutthebush.companyindex.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户登录
 *
 * @author LookOutTheBush
 * @date 2021/9/22 12:15 下午
 */
@RestController
@RequestMapping("users")
@Slf4j
public class UsersController {
    @Resource
    private IUsersService usersService;


    @PostMapping("createUser")
    public Result<Long> createUser(@RequestBody UsersDO usersDO){
        log.info("createUsers, {}", usersDO);
        Long id = null;
        try{
            id = usersService.createUser(usersDO);
        }catch (BizException e){
            return Result.error(e.getMessage());
        }
        return Result.success(id);
    }
}
